package com.stars.easyms.rest.exception;

import com.stars.easyms.base.constant.RestCodeConstants;
import com.stars.easyms.base.util.ExceptionUtil;

/**
 * rest接口业务相关异常：默认不告警，若想告警需使用BusinessRestAlarmException
 *
 * @author guoguifang
 * @date 2020-08-17 18:34
 * @since 1.6.1
 */
public class BusinessRestException extends Exception {

    /**
     * 返回错误编码
     */
    private String retCode;

    /**
     * 返回的错误显示信息
     */
    private String retMsg;

    /**
     * 返回的错误详细信息
     */
    private String errorDesc;

    public BusinessRestException(String retMsg) {
        super(retMsg);
        this.retCode = RestCodeConstants.DEFAULT_ERROR_CODE;
        this.retMsg = retMsg;
    }

    public BusinessRestException(String retMsg, Exception e) {
        super(ExceptionUtil.getNestedThrowable(e));
        this.retCode = RestCodeConstants.DEFAULT_ERROR_CODE;
        this.retMsg = retMsg;
        this.errorDesc = ExceptionUtil.getExceptionDesc(e);
    }

    public BusinessRestException(String retCode, String retMsg) {
        super(retMsg);
        this.retCode = retCode;
        this.retMsg = retMsg;
    }

    public BusinessRestException(String retCode, String retMsg, Exception e) {
        super(ExceptionUtil.getNestedThrowable(e));
        this.retCode = retCode;
        this.retMsg = retMsg;
        this.errorDesc = ExceptionUtil.getExceptionDesc(e);
    }

    public String getRetCode() {
        return retCode;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public String getErrorDesc() {
        return errorDesc;
    }
}
